package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.AnswerBean;
import com.magic.gre.entity.base.BaseListModel;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.AnswerContract;
import com.magic.gre.mvp.model.AnswerModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-01-08 19:12
 * 文件名: AnswerPresenrerImpl
 * 描述:
 */
public class AnswerPresenrerImpl extends BasePresenterImpl<AnswerContract.View, AnswerContract.Model>
        implements AnswerContract.Presenter {
    public AnswerPresenrerImpl(AnswerContract.View view) {
        super(view);
    }

    @Override
    protected AnswerContract.Model creatModel() {
        return new AnswerModelImpl();
    }

    @Override
    public void pGetSubs(String unitId) {
        mModel.mGetSubs(new CommonObserver<BaseListModel<AnswerBean>>(new TypeToken<BaseListModel<AnswerBean>>(){}.getType()) {
            @Override
            protected void onSuccess(BaseListModel<AnswerBean> answerBeanBaseListModel) {
                mView.vGetSubs(answerBeanBaseListModel.body);
            }

            @Override
            public void onError(int status, String msg) {

            }
        }, unitId);
    }

    @Override
    public void pSumbitResult(String unitId, int right, long cost_time,int total) {
        mModel.mSumbitReslut(new CommonObserver<BaseObjectModel<String>>(new TypeToken<BaseObjectModel<String>>(){}.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel<String> baseObjectModel) {
                mView.vSumbitResult(baseObjectModel.body);
            }

            @Override
            public void onError(int status, String msg) {

            }
        }, unitId, right, cost_time,total);
    }
}
